package com.object.model.execute.impl;

import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import com.object.model.ModelBeanName;
import com.object.model.execute.ModelExecute;
import com.object.model.execute.dto.AddRoleDto;
import com.object.module.lq.sys.entity.TRoleEntity;
import com.object.module.lq.sys.service.TRoleService;
import org.springframework.stereotype.Service;


@Service(ModelBeanName.ADD_ROEL_TOLL)
public class AddRoleTool implements ModelExecute {
    public String execute(String json) {
        // 假设location是一个JSON字符串，例如{"location": "北京"}
        // 使用Jackson库解析JSON
        AddRoleDto dto = JSONUtil.toBean(json, AddRoleDto.class);
        TRoleEntity entity = new TRoleEntity();
        entity.setReName(dto.getReName());
        SpringUtil.getBean(TRoleService.class).save(entity);
        return "添加成功";
    }
}